package com.example.test;

import android.app.Activity;
import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class SimpleListViewActivity extends Activity {
	TextView selection;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.list_view);
		ListView listView = (ListView) findViewById(R.id.list);
		listView.setAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, wordcup));
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				TextView t = (TextView)findViewById(R.id.selection);
				t.setText(wordcup[arg2]);
			}

		});
		/*
		 * ListView lv = getListView(); lv.setTextFilterEnabled(true);
		 */
		/*
		 * lv.setItemsCanFocus(false);
		 * lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
		 */

		// selection = (TextView) findViewById(R.id.selection);
		/*
		 * lv.setOnItemClickListener(new OnItemClickListener() {
		 * 
		 * @Override public void onItemClick(AdapterView<?> arg0, View arg1, int
		 * arg2, long arg3) { Toast.makeText(getApplicationContext(),
		 * ((TextView) arg1).getText(), Toast.LENGTH_SHORT).show(); }
		 * 
		 * });
		 */
		/*
		 * ListView listView = (ListView)findViewById(R.id.list);
		 * listView.setAdapter(new ArrayAdapter<String>(this,
		 * android.R.layout.simple_list_item_1,wordcup));
		 */

	}

	/* @Override */
	/*
	 * protected void onListItemClick(ListView l, View v, int position, long id)
	 * { selection.setText(wordcup[position]);
	 * Toast.makeText(getApplicationContext(), wordcup[position],
	 * Toast.LENGTH_SHORT).show(); }
	 */

	static final String[] wordcup = new String[] { "Algeria", "Argentina",
			"Australia", "Brazil", "Cote d'Ivoire", "Cameroon", "Chile",
			"Costa Rica", "Denmark", "England", "France", "Germany", "Ghana",
			"Greece", "Honduras", "Italy", "Japan", "Netherlands",
			"New Zealand", "Nigeria", "North Korea", "Paraguay", "Portugal",
			"Serbia", "Slovakia", "Slovenia", "South Africa", "South Korea",
			"Spain", "Switzerland", "United States", "Uruguay" };
}
